package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Department;
import cn.wolfcode.service.IDepartmentService;
import cn.wolfcode.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private IUserService userService;
    @Autowired
    private IDepartmentService departmentService;
    @RequestMapping("/wxlogin")
    public void login (String username, String password) {
        System.out.println("微信小程序调用接口！！！用户名:" + username + "密码:" + password);
        boolean login = userService.login(username, password);
        if (login) {
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
    }
    @RequestMapping("/wxdepts")
    @ResponseBody
    public List<Department> depts(){
        System.out.println("查询");
        return departmentService.listAll();
    }
}
